<!--- Based on sphinx versionwarning extension. Extension currently only works on READTHEDOCS -->
  <script>
    // Create a banner if we're not on the official docs site
    if (location.host == "docs.testing.ansible.com") {
      document.write('<div id="testing_banner_id" class="admonition important">');
      para = document.createElement('p');
      banner_text=document.createTextNode("This is a testing site. For the official docs go to https://docs.ansible.com/");
      para.appendChild(banner_text);
      element = document.getElementById('testing_banner_id');
      element.appendChild(para);
      document.write('</div>');
    }

    // Create a banner if we're not the latest version
    current_url = window.location.href;
    if ((current_url.search("latest") > -1) || (current_url.search("/{{ latest_version }}/") > -1)) {
     // no banner for latest release
    } else if (current_url.search("devel") > -1) {
      document.write('<div id="banner_id" class="admonition caution">');
      para = document.createElement('p');
      banner_text=document.createTextNode("You are reading the *devel* version of the Ansible documentation - most module documentation is currently missing as the modules have moved to collections. Until docs catches up to this change, use the version selection to the left if you want module documentation or the latest stable release version. The *devel* version is not guaranteed stable.");
      para.appendChild(banner_text);
      element = document.getElementById('banner_id');
      element.appendChild(para);
      document.write('</div>');
    } else {
      document.write('<div id="banner_id" class="admonition caution">');
      para = document.createElement('p');
      banner_text=document.createTextNode("You are reading an older version of the Ansible documentation. Use the version selection to the left if you want the latest stable released version.");
      para.appendChild(banner_text);
      element = document.getElementById('banner_id');
      element.appendChild(para);
      document.write('</div>');
    }
  </script>
